//
//  TeacherCallNameConfirmCell.m
//  AttendenceSys
//
//  Created by ld on 16/1/28.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "TeacherCallNameConfirmCell.h"

@implementation TeacherCallNameConfirmCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self initCell];
    }
    return self;
}

- (void)initCell
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    _nameLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, [UIScreen mainScreen].bounds.size.width-20-30-45, 25)];
    [_nameLab setBackgroundColor:[UIColor clearColor]];
    _nameLab.font = [UIFont systemFontOfSize:16];
    [_nameLab setTextAlignment:NSTextAlignmentLeft];
    _nameLab.textColor = [UIColor blackColor];
    [self.contentView addSubview:_nameLab];
    
    _callNameBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _callNameBtn.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-30-45,11,45,23);
    [_callNameBtn setTitle:@"缺席" forState:UIControlStateNormal];
    
    _callNameBtn.layer.masksToBounds = YES;
    _callNameBtn.layer.cornerRadius = 4.5;
    _callNameBtn.layer.borderWidth = 1.0;
    
    [_callNameBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
    [_callNameBtn addTarget:self action:@selector(callName:) forControlEvents:UIControlEventTouchUpInside];
    
    [_callNameBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
    [self.contentView addSubview:_callNameBtn];
    
    UIImageView* lineView = [[UIImageView alloc] initWithFrame:CGRectMake(0,CallNameCellHeight-1,[UIScreen mainScreen].bounds.size.width,1)];
    [lineView setBackgroundColor:RGB(240, 240, 240)];
    [self.contentView addSubview:lineView];
}

-(void)callName:(id)sender
{
    UIButton* btn = (UIButton*)sender;
    if (_delegate && [_delegate respondsToSelector:@selector(getIsSelect:)]) {
        [_delegate getIsSelect:btn.tag-CallNameTag];
    }
}

-(void)setselectCallName:(BOOL)bSelect
{
    if (bSelect) {
        _callNameBtn.backgroundColor = RGB(242, 94, 95);
        [_callNameBtn.layer setBorderColor:[UIColor clearColor].CGColor];
        [_callNameBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
    else
    {
        _callNameBtn.backgroundColor = [UIColor whiteColor];
        [_callNameBtn.layer setBorderColor:RGB(240, 240, 240).CGColor];
        [_callNameBtn setTitleColor:RGB(102, 102, 102) forState:UIControlStateNormal];
        
    }
}


@end
